package com.ruoyi.project.warehouse.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.project.warehouse.domain.RyInventoryCurrentStock;
import com.ruoyi.project.warehouse.domain.RyInventoryCurrentStockVo;
import com.ruoyi.project.warehouse.mapper.WareCurrentStockMapper;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.warehouse.mapper.RyLendingReturnRecordMapper;
import com.ruoyi.project.warehouse.domain.RyLendingReturnRecord;
import com.ruoyi.project.warehouse.service.IRyLendingReturnRecordService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 借出归还记录Service业务层处理
 * 
 * @author 萧雪
 * @date 2022-09-06
 */
@Service
public class RyLendingReturnRecordServiceImpl implements IRyLendingReturnRecordService 
{
    @Autowired
    private RyLendingReturnRecordMapper ryLendingReturnRecordMapper;

    /**
     * 查询借出归还记录
     * 
     * @param id 借出归还记录主键
     * @return 借出归还记录
     */
    @Override
    public RyLendingReturnRecord selectRyLendingReturnRecordById(Long id)
    {
        return ryLendingReturnRecordMapper.selectRyLendingReturnRecordById(id);
    }

    // /**
    //  * 修改i库存方法
    //  *
    //  * @param ryLendingReturnRecord
    //  * @return
    //  */
    // @Override
    // public int updateInventoryCurrenStock(RyLendingReturnRecord ryLendingReturnRecord) {
    //     return
    // }

    /**
     * 查询借出归还记录列表
     * 
     * @param ryLendingReturnRecord 借出归还记录
     * @return 借出归还记录
     */
    @Override
    public List<RyLendingReturnRecord> selectRyLendingReturnRecordList(RyLendingReturnRecord ryLendingReturnRecord)
    {
        return ryLendingReturnRecordMapper.selectRyLendingReturnRecordList(ryLendingReturnRecord);
    }

    /**
     * 新增借出归还记录
     * 
     * @param ryLendingReturnRecord 借出归还记录
     * @return 结果
     */
    @Transactional
    @Override
    public int insertRyLendingReturnRecord(RyLendingReturnRecord ryLendingReturnRecord)
    {
        Date dateTime= new Date();
        ryLendingReturnRecord.setLendTime(dateTime);
        ryLendingReturnRecordMapper.updateInventoryCurrenStock(ryLendingReturnRecord);
        return ryLendingReturnRecordMapper.insertRyLendingReturnRecord(ryLendingReturnRecord);
    }

    /**
     * 修改借出归还记录
     * 
     * @param ryLendingReturnRecord 借出归还记录
     * @return 结果
     */
    @Transactional
    @Override
    public int updateRyLendingReturnRecord(RyLendingReturnRecord ryLendingReturnRecord)
    {
        Date dateTime= new Date();
        ryLendingReturnRecord.setReturnTime(dateTime);
        ryLendingReturnRecordMapper.updateInventoryCurrenStock(ryLendingReturnRecord);
        return ryLendingReturnRecordMapper.updateRyLendingReturnRecord(ryLendingReturnRecord);
    }

    /**
     * 批量删除借出归还记录
     * 
     * @param ids 需要删除的借出归还记录主键
     * @return 结果
     */
    @Override
    public int deleteRyLendingReturnRecordByIds(Long[] ids)
    {
        return ryLendingReturnRecordMapper.deleteRyLendingReturnRecordByIds(ids);
    }

    /**
     * 删除借出归还记录信息
     * 
     * @param id 借出归还记录主键
     * @return 结果
     */
    @Override
    public int deleteRyLendingReturnRecordById(Long id)
    {
        return ryLendingReturnRecordMapper.deleteRyLendingReturnRecordById(id);
    }
}
